---
title: Branching Workflow
description: Complex decision trees requiring dynamic path selection based on content analysis
---

**Example Use-Cases**: Expert routing, content type detection, multi-path processing

Dynamic routing workflows provide intelligent path selection while maintaining predictable execution within each chosen branch.

<img 
  className="block dark:hidden" 
  src="/images/workflows-router-steps-light.png" 
  alt="Workflows router steps diagram"
/>
<img 
  className="hidden dark:block" 
  src="/images/workflows-router-steps.png" 
  alt="Workflows router steps diagram"
/>

## Example

```python branching_workflow.py
from agno.workflow import Router, Step, Workflow

def route_by_topic(step_input) -> List[Step]:
    topic = step_input.input.lower()

    if "tech" in topic:
        return [Step(name="Tech Research", agent=tech_expert)]
    elif "business" in topic:
        return [Step(name="Business Research", agent=biz_expert)]
    else:
        return [Step(name="General Research", agent=generalist)]

workflow = Workflow(
    name="Expert Routing",
    steps=[
        Router(
            name="Topic Router",
            selector=route_by_topic,
            choices=[tech_step, business_step, general_step]
        ),
        Step(name="Synthesis", agent=synthesizer),
    ]
)

workflow.print_response("Latest developments in artificial intelligence and machine learning", markdown=True)
```

## Developer Resources

- [Router Steps Workflow](/examples/concepts/workflows/05_workflows_conditional_branching/router_steps_workflow)

## Reference

For complete API documentation, see [Router Steps Reference](/reference/workflows/router-steps).